package com.eshop.domain;

import java.util.List;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;

public class PageResult<T> implements Serializable
{
    @ApiModelProperty("总数量")
    private long totalElements;
    @ApiModelProperty("内容")
    private List<T> content;
    
    public PageResult(final long totalElements, final List<T> content) {
        this.totalElements = totalElements;
        this.content = content;
    }
    
    public PageResult() {
    }
    
    public static <T> PageResultBuilder<T> builder() {
        return new PageResultBuilder<T>();
    }
    
    public long getTotalElements() {
        return this.totalElements;
    }
    
    public List<T> getContent() {
        return this.content;
    }
    
    public PageResult<T> setTotalElements(final long totalElements) {
        this.totalElements = totalElements;
        return this;
    }
    
    public PageResult<T> setContent(final List<T> content) {
        this.content = content;
        return this;
    }
    
    @Override
    public boolean equals(final Object o) {
        if (o == this) {
            return true;
        }
        if (!(o instanceof PageResult)) {
            return false;
        }
        final PageResult<?> other = (PageResult<?>)o;
        if (!other.canEqual(this)) {
            return false;
        }
        if (this.getTotalElements() != other.getTotalElements()) {
            return false;
        }
        final Object this$content = this.getContent();
        final Object other$content = other.getContent();
        if (this$content == null) {
            if (other$content == null) {
                return true;
            }
        }
        else if (this$content.equals(other$content)) {
            return true;
        }
        return false;
    }
    
    protected boolean canEqual(final Object other) {
        return other instanceof PageResult;
    }
    
    @Override
    public int hashCode() {
        final int PRIME = 59;
        int result = 1;
        final long $totalElements = this.getTotalElements();
        result = result * 59 + (int)($totalElements >>> 32 ^ $totalElements);
        final Object $content = this.getContent();
        result = result * 59 + (($content == null) ? 43 : $content.hashCode());
        return result;
    }
    
    @Override
    public String toString() {
        return "PageResult(totalElements=" + this.getTotalElements() + ", content=" + this.getContent() + ")";
    }
    
    public static class PageResultBuilder<T>
    {
        private long totalElements;
        private List<T> content;
        
        PageResultBuilder() {
        }
        
        public PageResultBuilder<T> totalElements(final long totalElements) {
            this.totalElements = totalElements;
            return this;
        }
        
        public PageResultBuilder<T> content(final List<T> content) {
            this.content = content;
            return this;
        }
        
        public PageResult<T> build() {
            return new PageResult<T>(this.totalElements, this.content);
        }
        
        @Override
        public String toString() {
            return "PageResult.PageResultBuilder(totalElements=" + this.totalElements + ", content=" + this.content + ")";
        }
    }
}
